package de.hwr.sudokuspielehr.io;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;

/**
 * Writer class.
 * 
 * @author J. Reischauer
 * 
 */
public class Writer {

	/**
	 * Line break character.
	 */
	public static final String LINE_SEPARATOR = System.getProperty("line.separator");

	/**
	 * Writes the List of given Strings to the given File. Overrides the file if
	 * needed.
	 * 
	 * @param pFile
	 *            the File handle to write content to
	 * @param pLines
	 *            the lines to write to the given File handle
	 * 
	 * @throws IOException
	 *             if the given file cannot be accessed
	 */
	public static void write(File pFile, List<String> pLines) throws IOException {
		try (FileWriter fw = new FileWriter(pFile)) {
			for (String s : pLines) {
				fw.write(s + LINE_SEPARATOR);
			}
			fw.flush();
		}
	}
}
